const rp  = require('request-promise')
var Agent = require('socks5-https-client/lib/Agent');
const key = 'D6806AC8-7DE6-4322-BED4-3258ACBBA30E';

function request(url) {
  return rp({
    url: `https://rest.coinapi.io${url}?apikey=${key}`,
    json: true,
    strictSSL: true,
    /*agentClass: Agent,
    agentOptions: {
      socksHost: 'localhost', // Defaults to 'localhost'.
      socksPort: 1086, // Defaults to 1080.
    }*/
  });
}
module.exports =  {
  getSymbols: () => {
    return request('/v1/symbols');
  },
  getAssets: () => {
    return request('/v1/assets');
  },
  getExchanges: () => {
    return request('/v1/exchanges')
  },
  getExchangerate: ({base,quote}) => {
    return request(`/v1/exchangerate/${base}/${quote}`);
  },
  getPeriods: () => {
    return request('/v1/ohlcv/periods');
  }
}
